<?PHP

class OP_LinksWidget extends OP_WidgetTemplate{
	function render(){
		$title = empty( $this->values['title'] ) ? __( 'Links' ) : apply_filters('widget_title', $this->values['title']);

		// Commented out because it was causing validation errors
		//$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);	
		
		wp_list_bookmarks(apply_filters('widget_links_args', array(
			'title_before' => $this->values['before_title'], 'title_after' => $this->values['after_title'],
			'show_images' => true, 'class' => 'linkcat'
		)));
			
	}
	
	function do_post($post){
		$title = strip_tags(stripslashes($post["title"]));
		return compact( 'title' );
	}
	
	function options(){
		$title = attribute_escape($this->values['title']);	
		echo '<p><label for="'.$this->widget->class.'-title-'.$this->values['number'].'">'._e('Title:').' <input class="widefat" id="'.$this->widget->class.'-title-'.$this->values['number'].'" name="'.$this->widget->class.'['.$this->values['number'].'][title]" type="text" value="'.$title.'" /></label></p>';
	}
	
}

$widget = new OP_Widget('links');
$widget->setMeta('OP Links',"Your site's links");
$widget->setDefaults(array('title'=>''));

$opw_links = new OP_LinksWidget($widget);
add_action('widgets_init', array($opw_links, 'init'));

?>